<template>
  <div class="article-item">
    <el-card class="article-card" >
      <div slot="header"  class="card-header clearfix"> 
        <strong class="title">{{data.title}}</strong>
        <span class="time">{{data.createdTime}}</span>
        <div class="attachments" v-show="data.attachments.length">
          <el-popover
            placement="top-start"
            title="附件"
            width="280"
            trigger="click"
          >
            <div>
              <div v-for="(item, index) in data.attachments" :key="`list_${data.id}_at_${index}`">
                <el-link :href="serverHost + item.split('@')[1]" target="_blank">
                  {{item.split('@')[0]}}
                </el-link>
              </div>
            </div>
            <el-badge slot="reference"  :value="data.attachments.length" >
              <el-button type="primary" size="mini" icon="el-icon-picture" circle > </el-button>
            </el-badge>
            
          </el-popover>
        </div>
      </div>
      <div class="content">
        {{data.content}}
      </div>
      <div class="tags">
        标签： 
        <el-tag size="mini" type="primary" style="margin:2px" v-for="(tag, i) in data.tags" :key="`data_${data.id}_tag_${tag.id}_${i}`" :title="tag.desc">
          {{tag.label}}
        </el-tag>
      </div>
    </el-card>
  </div>
</template>
<script>
import {SERVER_HOST} from '@/constant'
export default {
  components: {},
  props: {
    data: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data() {
    return {
      serverHost: SERVER_HOST
    }
  },
  computed: {
  },
  methods: {
  },
  created() {
  },
  mounted() {
  }
}
</script>
<style lang="scss" scoped>
@import "~$ui/styles/mixins/_index.scss";
.article-card{
  height: 210px; 
  // margin-bottom: 10px;
  .card-header{
    display:flex;
    flex-flow: row nowrap;
    align-items: center;
    .title{
      flex: 1;
      width: 0;
      margin-right: 20px;
      @include utils-ellipsis;
    }
    .time{
      flex: 0 0 auto;
    }
    .attachments{
      margin-left: 5px;
    }
  }
  .content{
    line-height: 24px;
    height: calc(24px * 3);
    overflow : hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  } 
  .tags{
    margin-top: 10px;
    padding-top: 5px;
    border-top: 1px solid #ebeef5;
    overflow: hidden;
    height: 30px;
  }
}
</style>